#pragma once
#include <Arbitrator.h>
#include <BWAPI.h>
#include <BWTA.h>
#include <InformationManager.h>
#include <DefenseManager.h>
using namespace BWAPI;
using namespace BWTA;

class AttackManager : Arbitrator::Controller<Unit*, double>
{
  public:
    AttackManager(Arbitrator::Arbitrator<Unit*,double>* arbitrator);
    ~AttackManager();
    virtual void onOffer(std::set<Unit*> units);
    virtual void onRevoke(Unit* unit, double bid);
    void onRemoveUnit(Unit* unit);
    virtual void update();
    virtual std::string getName() const;
    virtual std::string getShortName() const;

  private:
    Arbitrator::Arbitrator<Unit*, double>* arbitrator;
    std::set<Unit*> attackers;
    std::map<Unit*, int> nextCommand;
    BaseLocation* target;
    void findNewTarget();
    std::map<Unit*, int> lastAttackAttempt; // The last frame we tried to attack an enemy unit
    std::map<BaseLocation*, int> lastAttacked; // The last frame that an attempted attack was made on a base
    int retreatDrop; // the frame at which the AttackManager will drop all units for retreat
    static const int ATTACK_THRESHOLD = 24; // number of Mutalisks to have before start attacking. When reached half of this number, retreat.
    static const int RETREAT_THRESHOLD = 12;
};
